<div class="admin_form">
	<div class="page-header">
		<h1><?= $this->output->title() ?></h1>
	</div>
	<?= formOpenMultipart(site_url('admin/post/form'.($item->id? '/'.$item->id : ''))) ?>
		<?= input_row('title', $item->title, lang('title')) ?>
		<?= radios_row('published', array(lang('no'), lang('yes')), $item->published, lang('published')) ?>
		<?= inputdatetime_row('published_up', $item->published_up, lang('published_up')) ?>
		<script type="text/javascript">
			$(function()
			{
				$('.row_published_up .controls').datetimepicker({
					format: 'yyyy-MM-dd hh:mm:ss',
					language: 'en'
				});
			});
		</script>
		<?= dropdown_row('category_id', $categories, $item->category_id, lang('category'), 'class="input-large"') ?>
		<?= dropdown_row('type', $type, $item->type, lang('type'), 'class="input-large"') ?>
		<?= input_row('link_youtube', ($item->link_youtube? 'https://www.youtube.com/?v='.$item->link_youtube : ''), lang('link_youtube')) ?>
		<?= upload_row('image', lang('image'), 'accept="image/*" class="hasPreview" data-src="'.base_url().trim($this->config->item('folder_image'), '/').'/'.$item->image.'"') ?>
		<?= textarea_row('description', $item->description, lang('description')) ?>
		<?= textarea_row('content', $item->content, lang('content')) ?>
		<script type="text/javascript">
			<?php echo 'CKEDITOR.timestamp = "'.$timestamp.'";CKEDITOR.replace("content", {"toolbar":"Custom","filebrowserImageUploadUrl":"'.site_url('upload/ckeditor').'?ajax=1"});';
			?>
		</script>
		<?= input_row('tag', $item->tag, lang('tag')) ?>
		<?php
			$buttons = array();
			$buttons[] = formButton(array('type'=>'submit', 'class'=>'btn btn-primary'), lang('submit'));
			//$buttons[] = formButton(array('type'=>'reset'), lang('reset'));
		?>
		<?= buttons_row($buttons); ?>
		<?= formHidden('id', $item->id); ?>
	<?= formClose() ?>
</div>

<script type="text/javascript">
	$(document).ready(function()
	{
		changeType('#input_type');
		$('#input_type').change(function()
		{
			changeType(this);
		});
	});
	function changeType(ele)
	{
		type = parseInt($(ele).val());
		console.log(type);
		if(type==2)
		{
			$('.form-group.row_image').hide();
			$('.form-group.row_link_youtube').show();
		}
		else
		{
			$('.form-group.row_image').show();
			$('.form-group.row_link_youtube').hide();
		}
	}
</script>
